package com.yaozheng.vocationaltraining.view.checkpointsTrip;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yaozheng.vocationaltraining.R;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * 闯关练习view
 */
@EViewGroup(R.layout.item_checkpoints_trip)
public class ItemCheckpointsTripView extends LinearLayout {
    @ViewById
    TextView itemCheckpointsTripTextView;
    /**
     * 0正在闯的关 1未闯的关 2已闯关
     */
    int status;

    String valueStr;

    public ItemCheckpointsTripView(Context context) {
        super(context);
    }

    public ItemCheckpointsTripView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setTextValue(String valueStr) {
        this.valueStr = valueStr;
        itemCheckpointsTripTextView.setText(valueStr);
    }

    public String getTextValue() {
        return valueStr;
    }

    /**
     * @param status 0正在闯的关 1| 4未闯的关 2已闯关
     */
    public void setStatus(int status) {
        System.out.println(status);
        if (status == 0) {
            itemCheckpointsTripTextView.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.icon_exam_pass_now), null, null);
        } else if (status == 1 || status == 4) {
            itemCheckpointsTripTextView.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.icon_exam_pass_no), null, null);
        } else if (status == 2) {
            itemCheckpointsTripTextView.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.icon_exam_pass_done), null, null);
        }
        this.status = status;
    }

    /**
     * 得到状态 0正在闯的关 1未闯的关 2已闯关
     *
     * @return
     */
    public int getStatus() {
        return status;
    }
}
